package io.github.mayubao.kotlintest

import org.junit.Assert
import org.junit.Test

class Day2_NullOrNotNull{

    @Test
    fun testNull(){
        val vNull = null
        Assert.assertNull(vNull)
    }


    @Test
    fun testNotNull(){
        val vNull = "test"
        Assert.assertNotNull(vNull)
    }



    @Test
    fun testCanBeNull(){
        var vNull:String ? = "test"
        vNull = null
        Assert.assertNull(vNull)

        // ? append means the variable can be null
    }

    @Test
    fun testCanNotBeNull(){
        var vNull:String ? = "test"
        vNull = null
        vNull!!.toString()
        Assert.assertNull(vNull )
        // the keyword !! that modify the variable  means the current object can be null
        // and if the variable is null, the system will occur exception


//        kotlin.KotlinNullPointerException
//        at io.github.mayubao.kotlintest.Day2_NullOrNotNull.testCanNotBeNull(Day2_NullOrNotNull.kt:36)

    }


}